<%@ page language="java" contentType="text/html;charset=utf-8"
	pageEncoding="utf-8"%>

<%@ include file="/core/taglibs2.jsp"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/core/adminTopMeta.jsp"%>
<link href="<%=basePath%>/resources/zTree/zTreeStyle.css" rel="stylesheet"/>
<script src="<%=basePath%>/resources/zTree/jquery.ztree-2.6.min.js" type="text/javascript"></script>

<script type=text/javascript>
	var zTree ;
	var setting;
	var zNodes =[];

	setting = {
	
		async: true,
		
		isSimpleData : true,
		treeNodeKey : "id",
		treeNodeParentKey : "fatherId",
		
		//访问路径
		asyncUrl: "<%=basePath%>/admin/member/ajaxTuRecommend.shtml",    				//获取节点数据的URL地址
		asyncParam: ["id"],        	     						//获取节点数据时，必须的数据名称，例如：id、name
		asyncParamOther: ["loginName","${loginName}"],        	//其它参数 ( key, value 键值对格式)
		callback:{
			asyncSuccess: zTreeOnAsyncSuccess,
			expand: zTreeOnExpand
		}
	};

	
	
	$(document).ready(function(){
		
		refreshTree();
	});
	
	//异步返回的数据
	function zTreeOnAsyncSuccess(event, treeId, treeNode, msg) {
		 
		zTree.expandNode(treeNode, false, false,false);
	}

	//刷新数据
	function refreshTree(asyncUrl) {
		
		setting.asyncUrl = "<%=basePath%>/admin/member/ajaxTuRecommend.shtml";
		setting.asyncDataFilter = dataFilter;
		
		zTree = $("#tree").zTree(setting, zNodes);
		
	}
	
	//数据过滤
	function dataFilter(treeId, parentNode, childNodes) {
		childNodes=childNodes.menuList;
		
		return childNodes;
	}

	
	
	
	//展开的时候增加孙子
	function zTreeOnExpand(event, treeId, treeNode) {
		
		var nodes = zTree.getNodesByParam("fatherId", treeNode.id, treeNode);
		 
		for(var i =0; i<nodes.length; i++) {
			if(nodes[i].childNum>0){
				nodes[i].isParent=true;
				zTree.updateNode(nodes[i])
				zTree.reAsyncChildNodes(nodes[i], "refresh");
			}else{
				nodes[i].isParent=false;
			}
			
			
		}
	}
</script>
 
</head>

<body oncontextmenu="return false"><div class="loader"></div>
 										
	<div class="row">
		<div class="col-md-12">
			<div class="panel">
				<div class="panel-heading text-primary">
					<h3 class="panel-title">
						<i class="fa fa-cogs"></i> 直推代理商
						<span class="pull-right">
							<div class="btn-group code">
								<a href="#" class="dropdown-toggle" data-toggle="dropdown"
									title="Classes used"> 
								</a>
							</div> 
						</span>
					</h3>
				</div>

				<!-- /panel body -->
			</div>
		</div>

		<div class="col-md-12">
			<div class="panel panel-primary">
				<div class="panel-heading">
					<h3 class="panel-title  text-white" style="font-size: 17px;">
						直推代理商
					</h3>
				</div>
				<div class="panel-body">
					<form id="commitForm" name="commitForm"  method="post" action="admin/member/tuRecommend.shtml">
					 	 
						<table class="table table-bordered table-hover table-striped display" id="example">

							<tbody>
								<tr>
									<td style="vertical-align:middle;">
										用户名：
									 
										<input type="text"  name="loginName"  id="loginName" />
									 
										<button type="submit" class="btn btn-success "> 查 询 </button>
									 
										<span style="color: red;">${retMsg}</span>
									</td>
								</tr>

							</tbody>


						</table>
						<div class="table-responsive">
						<table class="table table-bordered table-hover table-striped display" id="example">

							<tbody>
								<tr>
									<td>
										<div style="margin:0 auto;width:100%">
											<div id="tree" name="tree" class="tree" ></div>
										</div>
									</td>
								</tr>

							</tbody>


						</table>
						</div>
						<table class="table table-bordered table-hover table-striped display" id="example">

							<tbody>
								<tr>
									<td>
										 
										<div style="margin:0 auto;width:100%;min-height: 500px;">
											<iframe id="show" name="show" src="admin/member/tuRecommendShow.shtml?id=${id}" frameborder="0"
												width="100%" height="500" scrolling="no"/>
										</div>
									</td>
								</tr>

							</tbody>


						</table>
					 
					</form>
				</div>
			</div>
			<!-- / Info Panel -->

		</div>

		<!-- /col-md-12 -->
	</div>
	<!--代码高亮end-->


	
</body>
</html>